<?php

namespace app\home\controller\user;

use think\Request;

class BaseController extends \app\home\controller\BaseController
{
    /**
     * 初始化
     */
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        if ($this->getMemberUid() <= 0) {
            if ($this->request->isAjax()) {
                $url = url('home/Public/login', ['url' => urlencode($_SERVER['HTTP_REFERER'])]);
                $this->error('请先登录！', $url, 'nologin');
            } else {
                $url = url('home/Public/login', ['url' => urlencode($_SERVER['REQUEST_URI'])]);
                $this->redirect($url);
            }
        }
    }

}